﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">  
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>后台管理中心</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
    <link href="js/plugins/custom.css" rel="stylesheet" />
</head>
<body class="nav-md" ms-controller="indexvm">
    <div class="container body">
        <div class="main_container">
            <div class="col-md-3 left_col">
                <div class="left_col scroll-view">
                    <div class="navbar nav_title" style="border: 0;">
                        <a href="javascript:void(0)" class="site_title"> <span>后台管理中心</span></a>
                    </div>
                    <div class="clearfix"></div>
                    <br />
                    <div style="border-bottom:dotted 1px #ffffff;padding-left:5px;padding-right:5px;"></div>
                    <!-- sidebar menu -->
                    <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
                        <div class="menu_section">
                            <!-- <h3>菜单</h3>-->

                            <ul class="nav side-menu">
                                <li>
                                    <a href="javascript:void(0);" ms-click="@OpenHome('indexpage.html')"><i class="fa fa-home"></i> 首页 </a>
                                </li>
                                <li ms-for="(index,el) in @MenuData" ms-if="el.SubItem[0]">
                                    <a><i ms-class="['fa',(el.MenuIco?el.MenuIco:'fa-clone')]"></i>{{el.MenuTxt}}<span class="fa fa-chevron-down"></span></a>
                                    <ul class="nav child_menu">
                                        <li ms-for="(index2,im) in el.SubItem"><a href="javascript:void(0);" ms-click="@OpenUrl(im)">{{im.MenuTxt}}</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <!-- /sidebar menu -->
                </div>
            </div>
            <!-- top navigation -->
            <div class="top_nav">
                <div class="nav_menu">
                    <nav class="" role="navigation">
                        <div class="nav toggle" style="width:300px;">
                            <a id="menu_toggle"><i class="fa fa-bars"></i></a>
                        </div>
                        <ul class="nav navbar-nav navbar-right">
                            <li class="">
                                <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                    设置
                                    <span class="fa fa-angle-down"></span>
                                </a>
                                <ul class="dropdown-menu dropdown-usermenu pull-right">
                                    <!--<li><a href="javascript:;"> 个人资料</a></li>
                                    <li>
                                        <a href="javascript:;">
                                            <span>设置</span>
                                        </a>
                                    </li>-->
                                    <!--<li><a href="javascript:;">帮助</a></li>-->
                                    <li><a ms-click="@LoginOut()"><i class="fa fa-sign-out pull-right"></i>退出</a></li>
                                </ul>
                            </li>

                        </ul>
                    </nav>
                </div>
            </div>
            <!-- /top navigation -->
            <!-- page content -->
            <div class="right_col" role="main">

                <script type="text/javascript">


                    //iframe自动设置高度
                    function getIframeWindow(obj) {
                        return obj.contentWindow || obj.contentDocument.parentWindow;
                    }
                    function getIframeHeight(obj) {
                        var idoc = getIframeWindow(obj).document;
                        if (idoc.body) {
                            return Math.max(idoc.body.scrollHeight, idoc.body.offsetHeight);
                        } else if (idoc.documentElement) {
                            return Math.max(idoc.documentElement.scrollHeight, idoc.documentElement.offsetHeight);
                        }
                    }
                    function setleftHeight(obj) {
                        var leftiframe = document.getElementById(obj);
                        leftiframe.height = 100;
                        leftiframe.height = getIframeHeight(leftiframe);
                    }
                    function SetCwinHeight() {
                        var iframeid = document.getElementById("main"); //iframe id
                        iframeid.height = document.documentElement.clientHeight + 15 + "px";//先给一个够小的初值,然后再长高.
                        if (iframeid) {
                            if (iframeid && !window.opera) {
                                if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) {
                                    iframeid.height = iframeid.contentDocument.body.offsetHeight;
                                } else if (iframeid.Document && iframeid.Document.body.scrollHeight) {
                                    iframeid.height = iframeid.Document.body.scrollHeight;
                                }
                            }
                        }
                    }

                    function reinitIframe() {

                        var iframe = document.getElementById("main");
                        try {
                            var bHeight = iframe.contentWindow.document.body.scrollHeight;
                            var dHeight = iframe.contentWindow.document.documentElement.scrollHeight + 50;
                            var height = Math.min(bHeight, dHeight);
                            iframe.height = height;
                        } catch (ex) { }
                    }

                    setInterval(reinitIframe, 800);
                    document.onkeydown = function (ev) {
                        var oEvent = ev || event;
                        if (oEvent.keyCode == 116 && document.getElementById('main')) {
                            var rightF = document.getElementById('main');
                            var rightFobj = getIframeWindow(rightF);
                            rightFobj.document.location.reload();
                            if (!/firefox/i.test(window.navigator.userAgent)) oEvent.keyCode = 0;
                            oEvent.cancelBubble = true;
                            return false;
                        }
                        if (oEvent.keyCode == 8 && document.getElementById('main')) {
                            if (!/firefox/i.test(window.navigator.userAgent)) oEvent.keyCode = 0;
                            oEvent.cancelBubble = true;
                            return false;
                        }
                    };

                    function iFrameHeight() {
                        var ifm = document.getElementById("main");
                        var subWeb = document.frames ? document.frames["main"].document : ifm.contentDocument;
                        if (ifm != null && subWeb != null) {
                            ifm.height = 15;
                            ifm.height = subWeb.body.scrollHeight + 30;
                        }
                    }
                </script>
                <div class="x_title">
                    <h6>首页>{{@newPageName}}</h6>

                    <div class="clearfix"></div>
                </div>

                <iframe name="main" id="main" marginwidth="0" onload="SetCwinHeight()" frameborder="0" ms-attr="{src:@nowPage}" scrolling="no" style="background-color:transparent;width:100%;min-height:500px;padding-left:5px;" allowtransparency="true" frameborder="0"></iframe>

            </div>
            <!-- /page content -->
            <div class="clearfix"></div>
            <!-- footer content -->
            <footer>
                <div class="pull-right">
                    版权所有
                </div>
                <div class="clearfix"></div>
            </footer>
            <!-- /footer content -->
        </div>
    </div>
    <!-- jQuery -->
    <script src="https://cdn.bootcss.com/jquery/2.2.3/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="/admin/js/layer/layer.js"></script>
    <script src="/admin/js/plugins/custom.js?1"></script>
    <script src="/admin/js/ComFunJS.js?v=20180101"></script>
    <script src="//cdn.bootcss.com/avalon.js/2.1.8/avalon.js"></script>
    <script type="text/javascript">

        var model = avalon.define({
            $id: "indexvm",
            MenuData: [],
            SelMenu:{},
            nowPage: "",
            newPageName: "",
            name: "",
            GetMenuData: function () {
                $.getJSON("/adapi/auth/menu", function (r) {
                    if (r.error == "") {
                        model.MenuData = r.result;
                        model.name = r.result1;
                        if (model.MenuData.length > 0) {
                            model.nowPage = "/admin/indexpage.html";
                        }
                    } else if (r.error.indexOf("登录") != -1) {
                        window.location.href = "/admin/login.html";
                    }

                })
            },
            OpenHome: function (url) {
                if (model.MenuData.length > 0) {
                    model.nowPage = url + "?r=" + Math.random();
                    model.newPageName = "";
                }
            },
            OpenUrl: function (el) {
                model.SelMenu = el;
                if (el) {
                    model.newPageName = el.MenuTxt;
                    if (el.MenuUrl.indexOf("?") > 0) {
                        model.nowPage = el.MenuUrl + "&r=" + Math.random();
                    } else {
                        model.nowPage = el.MenuUrl + "?r=" + Math.random();
                    }
                }
            },
            LoginOut: function () {
                ComFunJS.showConfirm("确认退出吗？", function () {
                    ComFunJS.delToken();
                    window.location = "login.html";
                }, "退出");
            },
            HasAuth: function (op) {
                var isVal = false;
                if (model.SelMenu && model.SelMenu.MenuAuth && op) {
                    if (model.SelMenu.MenuAuth.indexOf(op) > -1) {
                        isVal = true;
                    }
                }
                return isVal;
            }
        });
        avalon.ready(function () {
            if (ComFunJS.getToken()) {
                model.GetMenuData();
            }
            else {
                window.location.href = "/admin/login.html";
            }
        })
    </script>

</body>
</html>
